import React, {PureComponent} from "react";
import '../style.css'

class OpenAPIComponent extends PureComponent {

    constructor(props) {
        super(props);
        this.state = {
            iFrameHeight: '0px'
        }
    }

    updateState() {
        this.setState({
            "iFrameHeight":  (window.document.body.scrollHeight-150) + 'px'
        });
    }

    componentDidUpdate(prevProps, prevState, snapshot) {
        window.onresize = () => (
            this.updateState()
        );
    }

    render() {
        return (
            <div className='open_api_Content'>
                <iframe
                    style={{width:'100%', height:this.state.iFrameHeight}}
                    onLoad={() => {
                        this.updateState();
                    }}
                    ref="iframe"
                    // src="http://172.27.1.104:8084/swagger/#"
                    src="http://0.0.0.0:8084/swagger/#"
                    width="100%"
                    height={this.state.iFrameHeight}
                    frameBorder="0"
                    title="接入文档"
                />
            </div>
        )
    }
}

export default OpenAPIComponent